#!/usr/bin/env python

# Constants:
PACKAGE_NAME = 'bag_player'
NODE_NAME = 'bag_client'
NEXT_SERVICE = 'bag_player_next'

# -------
# Imports:
# -------
# ROS
import roslib; roslib.load_manifest(PACKAGE_NAME)
import rospy, cv, rosbag
from sensor_msgs.msg import CameraInfo, Image
from tf.msg import *
from bag_player.srv import *
from argparse import ArgumentParser

# -------------
class BagClient:
# -------------
    # -----------------
    def __init__(self):
    # -----------------
		# Initialize the node
		rospy.init_node(NODE_NAME)

		rospy.loginfo('+ Waiting for service....')
		rospy.wait_for_service(NEXT_SERVICE)
		self.callNext = rospy.ServiceProxy(NEXT_SERVICE, Next)
		rospy.loginfo('+ Done.')

    # ------
    # Public|
    # -----------
    def run(self):
    # -----------
		i = 0
		rospy.loginfo('+ Running')
		while True:
			rospy.loginfo('+ Iteration %i' % i)
			rospy.loginfo('  - Calling')
			self.callNext()
			
			i += 1
		rospy.loginfo('+ Done')

# -----------------------
if __name__ == '__main__':
# -----------------------
    # Create the node
	node = BagClient()
	node.run()
